﻿@model XPressify.Models.AlbumDetailsModel
@using XPressify.Data.Helpers
@using XPressify.Controllers
@using Omu.Awesome.Core;
@using Omu.Awesome.Mvc.Helpers;
@using XPressify.Models

@{
    ViewBag.Title = Model.Name;
    Layout = "~/Views/Shared/_Layout.cshtml";
}



    <h2 style="color:#222">
        
        @if(Model.Album.IsWall)
        {
            @:Wall
        }
        else if(Model.Album.IsProfile)
        {
            @:Profile
        }
        else
        {
            @Model.Album.Name
        }
        
        @if (Model.Album.IsWall)
        {
            @:files
        }
        else if (Model.Album.IsProfile)
        {
            @:photos
        }

    </h2>
    
    @if (!Model.Album.IsProfile && !Model.Album.IsWall)
    {
        <h3>@Model.Description</h3>    
    }



@if (Model.Location != "")
{
    <h4>Location: @Model.Location</h4>
}

<h4>
    by:
    @if (Model.Owner != null)
    {
        @Html.ActionLink(Model.Owner.FullName, "ProfileView", "Profile", new { id = Model.Owner.Id }, new { @class = "nobtn" })
    }
    else
    {
        @Html.ActionLink(Model.BaseSubjectName, "BaseSubjectDetails", "BaseSubject", new { id = Model.BaseSubjectId }, new { @class = "nobtn" })
    }
    *
    @Html.ActionLink(Model.Album.BaseSubject.FullName + "\'s albums", "AlbumViewerList", "Album", new { id = Model.Album.BaseSubject.Id }, new { })
</h4>
<br />
@if (Model.IsOwner)
{
    <div align="right">
    @(Html.MakePopupForm<AlbumController>(o => o.AlbumUploadFileNormal(Model.Id), title: "Upload", height: 340, width: 600, okText: "", resizable: false, refreshOnSuccess: false))
    @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumUploadFileNormal(Model.Id), "Add more files", new { @class = "abtn" }))
    </div>
}

<fieldset>
    
    <table>
        
        @{  var j = 0;
            var i = 0;
            for (i = 0; i < Model.AllFiles.Count(); i++)
            {
                <tr>
            
                    @for (j = i; j < Model.AllFiles.Count(); j++)
                    {
                    
                        <td>
                            @if (Model.AllFiles.ElementAt(j).MediaType == MediaType.Photo)
                            {
                                <a href='@Url.Action("ImageGallery", "Album", new { id = Model.AllFiles.ElementAt(j).Id })' class="nobtn">
                                    <img src="@Model.AllFiles.ElementAt(j).Path" alt="@Model.AllFiles.ElementAt(j).Name" title="@Model.AllFiles.ElementAt(j).Name" style="width: 200px;" class="nobtn"/>
                                </a>
                                
                            }
                            else if (Model.AllFiles.ElementAt(j).MediaType == MediaType.Video)
                            {
                                <a class="nobtn"@*"media {width:480, height:280}"*@ href="@Model.AllFiles.ElementAt(j).Path">@Model.AllFiles.ElementAt(j).FullName</a>
                            }
                            else if (Model.AllFiles.ElementAt(j).MediaType == MediaType.Audio)
                            {
                                <a href="@Model.AllFiles.ElementAt(j).Path" class="nobtn">@Model.AllFiles.ElementAt(j).FullName</a>
                            }
                            else
                            {
                                <a href="@Model.AllFiles.ElementAt(j).Path" class="nobtn">@Model.AllFiles.ElementAt(j).FullName</a>
                        
                            }
                            <br />
                            @Model.AllFiles.ElementAt(j).Name
                            <br />
                            @(((float)Model.AllFiles.ElementAt(j).Size / 1024)) KB
                        </td>
                        if ((j + 1) % 4 == 0)
                        {
                            break;
                        }
                    }
                    @{i = j;}
                
                 </tr>
            }
        }
       
    </table>
</fieldset>


@Html.Confirm("Are you sure you want to delete this post?", "myconfirmBtn", title: "Delete post", yesText: "Delete")
@Html.Confirm("Are you sure you want to delete this comment?", "myconfirmBtn1", title: "Delete comment", yesText: "Delete")
<div id="returnSuccessDelete"></div>
<div id="specialPeopleLikeList" style="display:none"></div>    

@if (Model.IsOwner)
{

    if (Model.Album.IsProfile == false && Model.Album.IsWall == false)
    {
        @(Html.MakePopupForm<AlbumController>(o => o.AlbumInfoEdit(Model.Id), title: "Info", height: 550, width: 600, okText: "Save", resizable: false, refreshOnSuccess: true))
        @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumInfoEdit(Model.Id), "Edit info", new { @class = "nobtn" }))
    }
    else
    {
        
        @(Html.MakePopupForm<AlbumController>(o => o.AlbumPrivacyEdit(Model.Id), title: "Info", height: 365, width: 500, okText: "Save", resizable: false, refreshOnSuccess: true))
        @(Html.PopupFormActionLink<AlbumController>(o => o.AlbumPrivacyEdit(Model.Id), "Edit info", new { @class = "nobtn" }))
    }
    <br />
}
<table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;width:553px">
    <tr>
        <th style="width:46px"></th>
        <th width="0px" style="padding: 0px 2px 0px 2px"> 
            @Model.Created.ToString("dd MMMM, yyyy a't' HH:mm")
            *
            @(Ajax.ActionLink("Like/Unlike", "PostLike", "Post", new { id = Model.AlbumPostDummyId }, new AjaxOptions { UpdateTargetId = Model.AlbumPostDummyId.ToString(), OnSuccess = "", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.InsertBefore, HttpMethod = "GET" }, new { @class = "nobtn" })) 
            *
            @(Ajax.ActionLink("People like this", "PostLikeList", "Post", new { id = Model.AlbumPostDummyId }, new AjaxOptions { UpdateTargetId = "specialPeopleLikeList", OnSuccess = "peopleLikeListSuccess", InsertionMode = System.Web.Mvc.Ajax.InsertionMode.Replace, HttpMethod = "GET" }, new { @class = "nobtn" }))
        </th>
    </tr>
</table>

@{var specialUpdateId = "";}
@foreach (var comment in Model.AllComments)
{   
        <div id="@comment.Id">    
            <table border="0" cellpadding="0" cellspacing="0" style="margin:0px;padding:0px;width:553px">
                <tr>
                    <th width="0px" style="padding: 0px 2px 0px 2px"> 
                        @Html.Raw(comment.Content)
                    </th>
                    @if (comment.BaseSubject.Id == Model.Viewer.Id || Model.IsOwner)
                    {
                    
                        <th style="padding: 0px 2px 0px 2px;vertical-align: top;text-align:right"> 
                            @Html.Partial("BtnPostCommentDelete", new BtnPostDeleteModel { PostId = comment.Id })
                        </th>
                    }
                </tr>
            </table>
        </div>
}

@{specialUpdateId = Model.AlbumPostDummyId + "Update";}
<div id="@specialUpdateId"></div>

@Html.Partial("WriteComment", new XPressify.Models.PostCommentModel { PostId = Model.AlbumPostDummyId, ContentText = "Write a comment...", ProfilePicturePath = Model.CurrentUserProfilePicturePath })
